﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace B.S.BasicData.Infrastructure.Interfaces
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    /// <typeparam name="T">实体</typeparam>
    public interface IBaseRepository<T>
    {
        /// <summary>
        /// 查询所有
        /// </summary>
        /// <returns>返回Sql语句</returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="eneity">要添加的参数</param>
        /// <returns>返回受影响行数</returns>
        int Add(T eneity);
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="eneity">要修改的参数</param>
        /// <returns>返回受影响行数</returns>
        int Update(T eneity);
        /// <summary>
        /// 查询单个
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>返回受影响行数</returns>
        T GetById(int id);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="eneity">要删除的参数</param>
        /// <returns>返回受影响行数</returns>
        int Delete(T eneity);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int BatchDeleteByExpress(Expression<Func<T, bool>> expression);

    }
}
